//
//  NormalNewsCell.swift
//  网易新闻
//
//  Created by wl on 15/11/14.
//  Copyright © 2015年 wl. All rights reserved.
//

import UIKit


class NormalNewsCell: NewsCell {

    @IBOutlet weak var newsImageView: UIImageView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var contributorLbl: UILabel!
    @IBOutlet weak var ptimeLbl: UILabel!
    @IBOutlet weak var browsenumLbl: UILabel!
    @IBOutlet weak var adsLbl: UILabel!

    override var newsModel: NewsModel? {
        didSet {
            self.setupSubView()
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.adsLbl.layer.masksToBounds = true
        self.adsLbl.layer.borderWidth = 1
        self.adsLbl.layer.cornerRadius = 5
        self.adsLbl.layer.borderColor = NAVIGATIONBAR_RED_COLOR.CGColor
       
        
        //func drawText(in rect: CGRect)
        // Initialization code
    }

    override func setSelected(selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
    func setupSubView() {

       self.newsImageView.sd_setImageWithURL(NSURL(string: self.newsModel!.imgsrc)!, placeholderImage: UIImage(named: "placeholder"))
        
        self.newsImageView.contentMode = UIViewContentMode.ScaleAspectFill
        self.newsImageView.clipsToBounds = true

        if self.newsModel?.type == 5 {
            self.adsLbl.hidden = true
        }else{
            self.adsLbl.hidden = false
        }
        self.titleLabel.text = self.newsModel?.title
        let str = ApplicationDelegate.fontSize()
        let f  =  CGFloat ( (str as NSString).floatValue)
        self.titleLabel.font = UIFont.systemFontOfSize(f)

        self.contributorLbl.text = self.newsModel?.contributor
        self.browsenumLbl.text = self.newsModel?.browsenum
        self.ptimeLbl.text = publicMethod.computationTimeDifference(self.newsModel!.ptime)
        if self.newsModel?.tags == nil {
            self.adsLbl.hidden = true
            
        } else {
            self.adsLbl.text = String(format: " %@%@",(self.newsModel?.tags)!,"    ")
        }
        self.adsLbl.textColor = NAVIGATIONBAR_RED_COLOR
        
        self.adsLbl.textAlignment = NSTextAlignment.Center

    }

}
// 版权属于原作者
// http://code4app.com (cn) http://code4app.net (en)
// 发布代码于最专业的源码分享网站: Code4App.com